<%@page import="java.util.List"%>
<%@page import="GetData.DataWS"%>
<%@page import="dktc_ws.Hocky"%>
<%@page import="dktc_ws.Namhoc"%> 
<%@page import="dktc_ws.Lophoc"%> 
<%@page import="dktc_ws.Monhoc"%> 
<%@page import="dktc_ws.Giangvien"%> 
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<% DataWS ws = new DataWS();
    List<Hocky> dshk = ws.laydanhsachhocky(-1);
    List<Namhoc> dsnh;
    Namhoc nh;
 %>
     

<%
            
        if (request.getMethod()=="GET")
                       {
            try
            {
                            out.print("<table id=\"rounded-corner\" summary=\"\">");
                            out.print("<thead>");
                            out.print("<tr>");
                            out.print("<th scope=\"col\" class=\"rounded-company\"></th>");
                            out.print("<th scope=\"col\" class=\"rounded\">Mã lớp</th>");
                            out.print("<th scope=\"col\" class=\"rounded\">Môn học</th>");
                            out.print("<th scope=\"col\" class=\"rounded\">Thứ</th>");
                            out.print("<th scope=\"col\" class=\"rounded\">Ca</th>");
                            out.print("<th scope=\"col\" class=\"rounded\">Phòng</th>");
                            out.print("<th scope=\"col\" class=\"rounded\">Số lượng đăng ký tối đa</th>");
                            out.print("<th scope=\"col\" class=\"rounded\">Đã đăng ký</th>");
                            out.print("<th scope=\"col\" class=\"rounded\">Sửa</th>");
                            out.print("<th scope=\"col\" class=\"rounded-q4\">Xóa</th>");
                            out.print("</tr>");
                            out.print("</thead>");       
                            out.print("<tbody>"); 
                            int mahk = 0;
                            mahk = Integer.parseInt(request.getParameter("mahocky"));
                            List<Lophoc> dslop = ws.laydanhsachlophoc(-1);
                            List<Monhoc> dsmh;
                            Monhoc mh;
                            for (int i=0;i<dslop.size();i++)
                            {
                                Lophoc item = dslop.get(i);
                                if (item.getMahk() != mahk)
                                    continue;
    
    
                                    out.print("<tr>");
                                    out.print("    <td><a href='?page=detail_class&id="+item.getMaLop()+"'>Danh sách</a></td>");
                                    out.print("    <td>"+ item.getMamh()+".C"+item.getMaLop()+"</td> ");
                                    out.print("<td>");
                                    dsmh = ws.laydanhsachmonhoc(item.getMamh());
                                    mh = dsmh.get(0);
                                    out.print(mh.getTenmh());
                                    out.print("</td>");
                                    out.print("    <td>" + item.getThu() + "</td> ");
                                    out.print("    <td>" + item.getCa() + "</td> ");
                                    int sophonghoc = ws.laySoPhong(item.getMaLop());
                                    String strsophong;
                                    if (sophonghoc != -1)
                                        strsophong = String.valueOf(sophonghoc);
                                    else
                                        strsophong = "N/A";
                                    out.print("    <td>" + strsophong + "</td> ");
                                    out.print("    <td>" + item.getSoluongdktoda() + "</td>");
                                    out.print("    <td>" + item.getSoluongdadk() + "</td>");
                                    out.print("    <td><a href=\"?page=edit_class&id=" + item.getMaLop() + "\"><img src=\"images/user_edit.png\" alt=\"\" title=\"\" border=\"0\" /></a></td>");
                                    out.print("    <td><a href=\"\" class=\"ask\"><img src=\"images/trash.png\" alt=\"\" title=\"\" border=\"0\" onclick=\"deleteClass(" + item.getMaLop() + ")\"/></a></td>"); 
                                    out.print("</tr>      ");
                            }
                                    out.print("</tbody>");
                                    out.print("</table>");

                     
                        }
            catch (Exception ex)
                       {
    }
                       }
    
    %>         
    